package com.clarencezero.mylover.service.impl;

import com.clarencezero.mylover.mapper.MemberMapper;
import com.clarencezero.mylover.param.Result;
import com.clarencezero.mylover.param.VO.UserInfoVO;
import com.clarencezero.mylover.param.entiry.LoginBean;
import com.clarencezero.mylover.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("memberService")
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Result sign(LoginBean bean) {
        Result result = new Result();
        int a = memberMapper.insertMember(bean);
        if (a > 0) {
            result.setCode(20000);
            result.setMsg("用户注册成功");
        } else {
            result.setCode(40000);
            result.setMsg("用户注册失败,清重新注册");
        }
        return result;
    }

    @Override
    public Result getAllUser() {
        Result result = new Result();
        List<UserInfoVO> resultList =  memberMapper.getAllUser();
        if (null != resultList && resultList.size() > 0) {
            result.setCode(20000);
            result.setMsg("获取用户成功");
            result.setData(resultList);
        } else {
            result.setCode(40000);
            result.setMsg("获取用户失败");
        }
        return result;
    }
}
